package deng.jpwh.hello;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.EntityTransaction;

import deng.jpwh.EntityManagerUtil;

public class HelloWorld2 {

	public static void main(String[] args) {
		
		EntityManager em = EntityManagerUtil.getEntityManagerFactory().createEntityManager();
		
		EntityTransaction tx = em.getTransaction();
		tx.begin();
		
		Message m = new Message();
		m.setText("Hello_" + System.currentTimeMillis());
		em.persist(m);
		
		List<?> ls = em.createQuery("from Message").getResultList();
		System.out.println(ls);
		
		tx.commit();
		em.close();
		EntityManagerUtil.shutdown();

	}

}
